# -*- coding: utf-8 -*-

''' Author: Susana Messias n.º 6046 '''

import numpy as np
import matplotlib.pyplot as plt

'''
source: http://matplotlib.sourceforge.net/mp1_examples/pylab_examples/barchart_demo.py
'''


'''
Creates the graphics.
'''
class Graphic:
    @staticmethod
    def createGraphic(data, establishment):
        lista = []
        for x in data.year:
            lista.append(data.countYearAndEstablishment(x, establishment))
            pass
        nBars = len( data.year )
        N = 11
        menMeans = tuple(lista)


        ind = np.arange(N)  # the x locations for the groups
        width = 0.35       # the width of the bars


        plt.subplot(111)
        rects1 = plt.bar(ind + width * 2, menMeans, width,
                            color='y')

        plt.ylabel('Quantity of Teachers')
        plt.xlabel('Years')
        plt.title('Graphic')
        plt.xticks(ind + width * 5 / 2, ('2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010') )



            # attach some text labels
        def autolabel(rects):
            for rect in rects:
                height = rect.get_height()
                plt.text(rect.get_x()+rect.get_width()/2, 0.9*height, '%d'%int(height),
                        ha='center', va='bottom')

        autolabel(rects1)


        plt.show()
        pass
    
    '''
    Creates the graphic for Quantity of Teachers by Degree
    '''
    @staticmethod
    def createGraphic2(data, establishment, degree):
        lista = []
        for x in data.year:
            lista.append(data.countDegreeYearEstablishment(x, establishment, degree))
            pass
        nBars = len( data.year )
        N = 11
        menMeans = tuple(lista)


        ind = np.arange(N)  # the x locations for the groups
        width = 0.35       # the width of the bars


        plt.subplot(111)
        rects1 = plt.bar(ind + width * 2, menMeans, width,
                            color='y')

        plt.ylabel('Quantity of Teachers by Degree')
        plt.xlabel('Years')
        plt.title('Graphic')
        plt.xticks(ind + width * 5 / 2, ('2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010') )



            # attach some text labels
        def autolabel(rects):
            for rect in rects:
                height = rect.get_height()
                plt.text(rect.get_x()+rect.get_width()/2, 0.9*height, '%d'%int(height),
                        ha='center', va='bottom')

        autolabel(rects1)


        plt.show()

        pass

    '''
    Creates the graphic for Quantity of Teachers by Categorie
    '''
    @staticmethod
    def createGraphic3(data, establishment, categorie):
        lista = []
        for x in data.year:
            lista.append(data.countYearEstablishmentAndCategorie(x, establishment, categorie))
            pass
        nBars = len( data.year )
        N = 11
        menMeans = tuple(lista)


        ind = np.arange(N)  # the x locations for the groups
        width = 0.35       # the width of the bars


        plt.subplot(111)
        rects1 = plt.bar(ind + width * 2, menMeans, width,
                            color='y')

        plt.ylabel('Quantity of Teachers by Categorie')
        plt.xlabel('Years')
        plt.title('Graphic')
        plt.xticks(ind + width * 5 / 2, ('2000', '2001', '2002', '2003', '2004', '2005', '2006', '2007', '2008', '2009', '2010') )



            # attach some text labels
        def autolabel(rects):
            for rect in rects:
                height = rect.get_height()
                plt.text(rect.get_x()+rect.get_width()/2, 0.9*height, '%d'%int(height),
                        ha='center', va='bottom')

        autolabel(rects1)


        plt.show()
